<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <input type="text" id="ipt" width="200px" />
    <script>
        // 防抖
        var timer = null
        function fn(){
            clearTimeout(timer)
            timer = setTimeout(()=>{
                console.log('执行啦');
            },500)
        }
        let tt = document.getElementById('ipt')
        tt.addEventListener('keyup',function(){
            fn()
        })
    </script>
  </body>
</html>
